package vivek.project.pocketmoney.expenses.model
{
	import vivek.project.pocketmoney.admin.model.AdminConstants;
	import vivek.project.pocketmoney.common.utils.CommonConstants;
	import vivek.project.pocketmoney.common.utils.StringUtils;

	public class CITIBankLoader extends AccountLoaderImpl
	{
		private static var iciciBankLoader:CITIBankLoader=null;
		private var delimiter:String="\t";
		private var numCols:int=6;
		private var dataStart:int=10;
		private var bankName:String="CITI";

		public function CITIBankLoader()
		{
			dateFormat="DD-MM-YY";
			categoryMatch.push({matchString: "STANDING", catid: 11});
			categoryMatch.push({matchString: "Interest", catid: 43});
			categoryMatch.push({matchString: "SALARY", catid: 14});

		}

		public static function getInstance():CITIBankLoader
		{
			if (iciciBankLoader == null)
				iciciBankLoader=new CITIBankLoader();
			return iciciBankLoader;
		}

		override public function checkValiditiy(fileContent:String):Boolean
		{
			return false;
		}

		override public function getExpenseRecords(fileContent:String, account:Object):Array
		{
			var txnrecords:Array;
			var txntype:int=CommonConstants.WITHDRAWAL;
			var amount:Number=0;
			//var amount3:Number=0;
			txnrecords=loadExpenseData(fileContent, delimiter, numCols);
			var expenseRecords:Array=new Array();
			for each (var obj:Object in txnrecords)
			{
				if (obj[2] != "" || obj[3] !== "")
				{
					try
					{
						var expenseRecord:Object=new Object();
						if (obj[2] != "")
						{
							txntype=CommonConstants.WITHDRAWAL
							amount=new Number(StringUtils.trimSpecialChar(obj[2]));
						}
						else
						{
							amount=new Number(StringUtils.trimSpecialChar(obj[3]));
							txntype=CommonConstants.DEPOSIT
						}
						//(date:String, amount:Number, memo:String, txnType:int, account:int, category:int, instr:String):
						expenseRecord=createExpenseObject(obj[0], amount, obj[1], txntype, account.am_accountid, 24, obj[4]);
						if (!isNaN(expenseRecord.amount))
							expenseRecords.push(expenseRecord);
					}
					catch (error:Error)
					{
					}
				}
			}
			return expenseRecords;
		}
	}
}